package com.csw.xuxianParent.xuxianBase.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.csw.xuxianParent.xuxianBase.dao.Label;
import com.csw.xuxianParent.xuxianBase.service.LabelService;
import com.csw.xuxianParent.xuxianCommon2.entity.Result;
import com.csw.xuxianParent.xuxianCommon2.entity.StatusCode;

@RestController
@RequestMapping("label")
@CrossOrigin
public class LabelController {
	@Autowired
	private LabelService labelService;

	// 根据id查询标记
	@GetMapping("{id}")
	public Result findLabelById(@PathVariable("id") String id) {
		/* int i=1/0;//模拟异常 */
		return new Result(true, StatusCode.OK, "查询成功", labelService.getLabelById(id));
	}

	// 新增标签
	@PostMapping("addLabel")
	public Result addLabel(@RequestBody Label label) {
		return new Result(true, StatusCode.OK, "新增成功", labelService.addLabel(label));
	}
}
